|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectcontrolP5.Controller
controlP5.Range
public class Range
a slider.
/**
* ControlP5 Slider. Horizontal and vertical sliders,
* with and without tick marks and snap-to-tick.
* by andreas schlegel, 2010
*/
import controlP5.*;
ControlP5 controlP5;
int myColor = color(0,0,0);
int sliderValue = 100;
int sliderTicks1 = 100;
int sliderTicks2 = 30;
void setup() {
size(400,400);
controlP5 = new ControlP5(this);
// add a vertical slider
controlP5.addSlider("slider",0,200,128,20,100,10,100);
// create another slider with tick marks, now without
// default value, the initial value will be set according th
// the value of variable sliderTicks2 then.
controlP5.addSlider("sliderTicks1",0,255,100,100,10,100);
Slider s1 = (Slider)controlP5.controller("sliderTicks1");
s1.setNumberOfTickMarks(5);
// add horizontal sliders
controlP5.addSlider("sliderValue",0,255,128,200,180,100,10);
controlP5.addSlider("sliderTicks2",0,255,128,200,220,100,10);
Slider s2 = (Slider)controlP5.controller("sliderTicks2");
s2.setNumberOfTickMarks(7);
// use Slider.FIX or Slider.FLEXIBLE to change the slider handle
// by default it is Slider.FIX
s2.setSliderMode(Slider.FLEXIBLE);
}
void draw() {
background(sliderTicks1);
fill(sliderValue);
rect(0,0,width,100);
fill(myColor);
rect(0,300,width,70);
fill(sliderTicks2);
rect(0,370,width,30);
}
void slider(float theColor) {
myColor = color(theColor);
println("a slider event. setting background to "+theColor);
}
| Field Summary | |
|---|---|
int |
alignValueLabel
|
static int |
FIX
|
static int |
FLEXIBLE
|
int |
valueLabelPositioning
|
| Fields inherited from interface controlP5.ControlP5Constants |
|---|
acceptClassList, ACTIVE, ALT, ARC, ARRAY, BACKSPACE, BOOLEAN, BOTTOM, CENTER, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, IMAGE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LINE, LOAD, MENU, METHOD, MOVE, OVER, PI, PRESSED, PRINT, RELEASE, RESET, RIGHT, SAVE, SHIFT, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TWO_PI, UP, VERBOSE |
| Constructor Summary | |
|---|---|
Range(ControlP5 theControlP5,
ControllerGroup theParent,
java.lang.String theName,
float theMin,
float theMax,
float theDefaultMinValue,
float theDefaultMaxValue,
int theX,
int theY,
int theWidth,
int theHeight)
|
|
| Method Summary | |
|---|---|
void |
addToXMLElement(ControlP5XMLElement theElement)
|
float[] |
arrayValue()
|
void |
draw(processing.core.PApplet theApplet)
the default draw function for each controller extending superclass Controller. |
TickMark |
getTickMark()
|
float |
highValue()
|
float |
lowValue()
|
void |
mouseReleased()
|
void |
mouseReleasedOutside()
|
void |
onLeave()
|
void |
setDraggable(boolean theFlag)
|
Controller |
setHeight(int theValue)
set the height of the slider. |
void |
setHighValue(float theValue)
|
void |
setLowValue(float theValue)
|
void |
setMax(float theValue)
set the maximum value of the slider. |
void |
setMin(float theValue)
set the minimum value of the slider. |
void |
setNumberOfTickMarks(int theNumber)
|
void |
setSliderMode(int theMode)
|
void |
setValue(float theValue)
set the value of the range-slider. |
Controller |
setWidth(int theValue)
set the width of the slider. |
void |
showTickMarks(boolean theFlag)
|
void |
snapToTickMarks(boolean theFlag)
|
void |
update()
updates the value of the controller without having to set the value explicitly. |
void |
updateInternalEvents(processing.core.PApplet theApplet)
TODO |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int FIX
public static final int FLEXIBLE
public int alignValueLabel
public int valueLabelPositioning
| Constructor Detail |
|---|
public Range(ControlP5 theControlP5,
ControllerGroup theParent,
java.lang.String theName,
float theMin,
float theMax,
float theDefaultMinValue,
float theDefaultMaxValue,
int theX,
int theY,
int theWidth,
int theHeight)
theControlP5 - ControlP5theParent - ControllerGrouptheName - StringtheMin - floattheMax - floattheDefaultValue - floattheX - inttheY - inttheWidth - inttheHeight - int| Method Detail |
|---|
public void setSliderMode(int theMode)
theMode - intpublic void updateInternalEvents(processing.core.PApplet theApplet)
Controller
updateInternalEvents in interface ControllerInterfaceupdateInternalEvents in class ControllerControllerInterface.updateInternalEventspublic void draw(processing.core.PApplet theApplet)
Controller
draw in interface CDrawabledraw in interface ControllerInterfacedraw in class ControllertheApplet - PAppletControllerDisplaypublic void setValue(float theValue)
setValue in class ControllertheValue - floatpublic void update()
Controller
update in interface ControllerInterfaceupdate in class Controllerpublic void setDraggable(boolean theFlag)
public float[] arrayValue()
arrayValue in class Controllerpublic void setMin(float theValue)
setMin in class ControllertheValue - floatpublic void setMax(float theValue)
setMax in class ControllertheValue - floatpublic float lowValue()
public float highValue()
public void setLowValue(float theValue)
public void setHighValue(float theValue)
public Controller setWidth(int theValue)
setWidth in class ControllertheValue - intpublic Controller setHeight(int theValue)
setHeight in class ControllertheValue - intpublic void mouseReleased()
public void mouseReleasedOutside()
public void onLeave()
public void setNumberOfTickMarks(int theNumber)
public void showTickMarks(boolean theFlag)
public void snapToTickMarks(boolean theFlag)
public TickMark getTickMark()
public void addToXMLElement(ControlP5XMLElement theElement)
theElement - ControlP5XMLElement
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||